home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE15 / CPPCLASS / OWLDEL / delowl.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-07-17  |  2.8 KB  |  115 lines

  1. unit Delowl;
  2.  
  3. interface
  4.   uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  5.   Forms, CPPCom;
  6.  
  7. type
  8.  
  9. TDelOwlControl = class(TControl)
  10.   private
  11.     { Private declarations }
  12.  
  13.      FOnMessage     : TMessageEvent;
  14.      procedure FOnMessageExported(aMsg, wParam : Word; lParam: Longint);
  15.        cdecl; export;
  16.  
  17.   protected
  18.     { Protected declarations }
  19.     OWLHelpControl : TCOMInterface;
  20.     procedure VisibleChanging; override;
  21.     procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  22.  
  23.   public
  24.     { Public declarations }
  25.       constructor Create(AOwner: TComponent); override;
  26.       destructor Destroy;    override;
  27.       procedure  Invalidate; override;
  28.       procedure  Repaint;    override;
  29.       procedure  Update;     override;
  30.   published
  31.     { Published declarations }
  32.  
  33.     property OnClick;
  34.     property OnDblClick;
  35.     property OnDragDrop;
  36.     property OnDragOver;
  37.     property OnEndDrag;
  38.     property OnMouseDown;
  39.     property OnMouseMove;
  40.     property OnMouseUp;
  41.     property Visible;
  42.   end;
  43.  
  44. implementation
  45.  
  46. function _COMClassConstructor(parentHWnd : hWnd):
  47.           TCOMInterface; cdecl; far; external 'OWLDEL'
  48.                   name '_COMCLASSCONSTRUCTOR';
  49.  
  50. procedure _COMClassDestructor(mySlider : TCOMInterface); cdecl;
  51.                      far;  external 'OWLDEL'
  52.                      name '_COMCLASSDESTRUCTOR';
  53.  
  54.  
  55.  
  56. constructor TDelOwlControl.Create(AOwner: TComponent);
  57. begin
  58.   inherited Create(AOwner);
  59.  
  60.   if (Owner is TWinControl) then
  61.       OWLHelpControl  := _COMClassConstructor(TWinControl(Owner).Handle);
  62.  
  63.   if OWLHelpControl = nil then abort;
  64.  
  65.   if not (csDesigning in ComponentState) then
  66.      OWLHelpControl.SetOnMessage(FOnMessageExported);
  67.  
  68.   Width    := 120;
  69.   Height   := 40;
  70.   {sync OWL and the VCL control}
  71.   Visible  := not Visible;
  72.   Visible  := not Visible;
  73. end;
  74.  
  75. destructor TDelOwlControl.Destroy;
  76. begin
  77.    _COMClassDestructor(OWLHelpControl);
  78.    OWLHelpControl := nil;
  79.   inherited Destroy;
  80. end;
  81. procedure  TDelOwlControl.Invalidate;
  82. begin
  83.   OWLHelpControl.Invalidate;
  84. end;
  85.  
  86. procedure  TDelOwlControl.Repaint;
  87. begin
  88.    OWLHelpControl.Repaint;
  89. end;
  90.  
  91. procedure  TDelOwlControl.Update;
  92. begin
  93.   OWLHelpControl.Update;
  94. end;
  95.  
  96. procedure TDelOwlControl.FOnMessageExported(aMsg, wParam : Word; lParam: Longint);
  97. begin
  98.   if (csDesigning in ComponentState) or
  99.      (csLoading in ComponentState)then Exit;
  100.   Perform(aMsg, wParam, lParam);
  101. end;
  102.  
  103. procedure TDelOwlControl.VisibleChanging;
  104. begin
  105.  OWLHelpControl.SetVisible(wordbool(not Visible));
  106. end;
  107.  
  108. procedure TDelOwlControl.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
  109. begin
  110.   inherited SetBounds(ALeft, ATop, AWidth, AHeight);
  111.   OWLHelpControl.SetBounds(ALeft, ATop, AWidth, AHeight);
  112. end;
  113.  
  114. end.
  115.